<template>
  <div class="app-container">
    <div class="zd3">
      <!-- <div class="zd3-title">
        <p>
          <span>公司</span>
          <input v-model="searchData.orderNumber" type="text" placeholder="请选择公司" />
        </p>
        <p>
          <span>部门</span>
          <input v-model="searchData.suppliesName" type="text" placeholder="请选择部门" />
        </p>
        <el-button size="small" type="success" @click="getList">查询</el-button>
        <el-button size="small" @click="resetList">重置</el-button>
      </div> -->
      <div class="zd3-btm">
        <el-table
          :data="tableData"
          style="width: 100%;margin-bottom: 20px;"
          row-key="id"
          border
          default-expand-all
          :tree-props="{children: 'children', hasChildren: 'hasChildren'}">
          <el-table-column type="index" align="center" label="序号" width="80"></el-table-column>
          <el-table-column prop="name" align="center" label="类别名称" width="180"></el-table-column>
          <el-table-column prop="shiyongNum" align="center" label="在用"></el-table-column>
          <el-table-column prop="xianzhiNum" align="center" label="闲置"></el-table-column>
          <el-table-column prop="jiechuNum" align="center" label="借出"></el-table-column>
          <el-table-column prop="yibaofeiNum" align="center" label="已报废"></el-table-column>
          <el-table-column prop="diaoboNum" align="center" label="调拨中"></el-table-column>
          <el-table-column prop="baoxiuNum" align="center" label="报修中"></el-table-column>
          <el-table-column prop="weixiuNum" align="center" label="维修中"></el-table-column>
          <el-table-column align="center" label="合计">
            <template slot-scope="scope">
              <span>{{scope.row.shiyongNum*1+scope.row.xianzhiNum*1+scope.row.jiechuNum*1+scope.row.yibaofeiNum*1+scope.row.diaoboNum*1+scope.row.baoxiuNum*1+scope.row.weixiuNum*1}}</span>
            </template>
          </el-table-column>
        </el-table>
        
      </div>
    </div>
  </div>
</template>

<script>
// import { gebumenshiyong } from "@/api/home"
import { getSeting,gebumenZichan } from '@/api/caigou'
export default {
  data() {
    return {
      content: "",
      total: 1,
      page: 1,
      dialogVisible: false,  //弹窗
      drawer: false,   //抽屉
      showHeader: true,
      loading: true,
      tableData: [],   //数据列表
      tempData: {},    //修改增加承载数据
      searchData: {},  //搜索承载数据
      time: '',       //购入日期
      proData:[],     //资产数据
      tempIndex: -1,
      ifydata: [],
      checkList: []
    };
  },
  mounted() {
    this.getList()
    // this.getSet()
  },
  methods: {
    /**
     * 获取分类列表
     */
    getList() {
      gebumenZichan(this.searchData).then(res => {
        console.log('bumen',res);
        let temparr = []
        for(let key in res.data){
          console.log(key)
          let tempobj = {
            name:key,
            shiyongNum: 0,
            xianzhiNum: 0,
            jiechuNum: 0,
            yibaofeiNum: 0,
            diaoboNum: 0,
            baoxiuNum: 0,
            weixiuNum: 0
          }
          res.data[key].forEach(element => {
            console.log(element)
            if(element.levels === '使用中'){
              tempobj.shiyongNum = element.nums
            }else if(element.levels === '闲置'){
              tempobj.xianzhiNum = element.nums
            }else if(element.levels === '借出'){
              tempobj.jiechuNum = element.nums
            }else if(element.levels === '已报废'){
              tempobj.yibaofeiNum = element.nums
            }else if(element.levels === '调拨中'){
              tempobj.diaoboNum = element.nums
            }else if(element.levels === '报修中'){
              tempobj.baoxiuNum = element.nums
            }else if(element.levels === '维修中'){
              tempobj.weixiuNum = element.nums
            }
          });
          temparr.push(tempobj)
        }
        console.log(temparr)
        this.tableData = temparr;
        this.loading = false;
      })
    },
    /**
     * 获取设置
     */
    getSet(){
      getSeting({}).then(res => {
        console.log(res)
      })
    },
    designUpFile(item){
      formData.append("file", item.file)
      importDaoshiCaigou(formData).then(res => {
        console.log(res)
        this.$message({
          message: res.data.message,
          type: 'success'
        })
      })
    },
    goPrev(page) {
      console.log(page)
      this.page--
      this.getList()
    },
    goNext(page) {
      console.log(page)
      this.page++
      this.getList()
    },
    goPage(page){
      console.log(page)
      this.page = page
      this.getList()
    },
    resetList() {
      this.searchData = {};
    },
  }
};
</script>

<style lang="scss" scoped>
.orderStatus {
  display: flex;
	justify-content: center;
  > p {
    padding: 0px 5px;
    color: #fff;
    font-size: 12px;
    border-radius: 2px;
    margin: 0 0px 0 0;
  }
  .blue {
    background: #3a87ad;
  }
  .green {
    background: #18a05e;
  }
  .yellow {
    background: #ff7a0e;
  }
  .red {
    background: #c60000;
  }
  .zise{
    background: #c7ab10
  }
}
.godetail{
  font-size: 14px;
  color: #18A05E;
  cursor: pointer;
}
/deep/.el-divider {
	background-color: #18A05E;
	position: relative;
}
.fanwei{
  padding-right: 20px;
}
/deep/.el-divider--horizontal {
  margin: 30px 0;
}
/deep/.el-divider__text {
	color: #18A05E;
  font-size: 16px;
}
/deep/.el-button--primary {
  color: #fff;
  background-color: #18a05e !important;
  border-color: #18a05e !important;
}
/deep/.el-button--primary:hover,
.el-button--primary:focus {
  background: #18a05e !important;
  border-color: #18a05e !important;
  color: #fff !important;
}
/deep/.el-button:hover,
.el-button:focus {
  color: #18a05e;
  background-color: transparent;
}
/deep/.el-button--primary {
  color: #fff;
  background-color: #18a05e;
  border-color: #18a05e;
}
/deep/.el-button--text {
  color: #00c666 !important;
}
.upload-demo{
  margin-left: 10px;
}
.app-container {
  padding: 10px;
}
.ellisp{
	width: 100%;
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
	overflow: hidden;
	text-align: left;
}
.rolestip {
  width: 100%;
  display: flex;
  justify-content: center;
}
.inps {
  width: 100%;
  height: 32px;
  line-height: 32px;
  padding-left: 10px;
  background: none;
  border: none;
  color: #333;
}
.inps-active {
  width: 100%;
  height: 32px;
  line-height: 32px;
  padding-left: 10px;
  // background:#ccc;
  border: none;
  color: #333;
}
.s-img{
  width: 80px;
  height: 80px;
}
.zd3-title {
	height: 70px;
	display: flex;
	align-items: center;
	padding: 0 20px;
	position: relative;
	background: #ffffff;
	border-radius: 8px;
	border: 1px solid rgba(0, 0, 0, 0.1);

	> p {
		font-size: 14px;
		color: #333;
		margin-right: 20px;

		> span {
			padding-right: 20px;
		}

		> input {
			width: 150px;
			height: 32px;
			// background: #ccc;
			border-radius: 3px;
			border: 1px solid #ccc;
			padding-left: 10px;
			color: #333;
		}
	}

	> h3 {
		// width: 64px;
		height: 32px;
		background: #18a05e;
		border-radius: 3px;
		margin: 0 30px 0 0;
		padding: 0 15px;
		color: #fff;
		font-size: 14px;
		line-height: 32px;
		font-weight: 100;
		text-align: center;
		cursor: pointer;
	}

	> h4 {
		padding: 0 15px;
		height: 32px;
		border-radius: 3px;
		border: 1px solid rgba(0, 0, 0, 0.1);
		color: #333;
		font-size: 14px;
		line-height: 32px;
		font-weight: 100;
		text-align: center;
		cursor: pointer;
	}
}
/deep/.el-pagination.is-background .el-pager li:not(.disabled).active {
  background-color: #18a05e;
  color: #fff;
}
.zd3-btm /deep/.btn-prev:after {
  content: "上一页";
}
.zd3-btm /deep/.btn-next:before {
  content: "下一页";
}
.zd3-btm /deep/.btn-prev,
.zd3-btm /deep/.btn-next {
  width: 65px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}
.zd3-btm {
  background: rgba(255, 255, 255, 1);
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  // margin-top: 10px;
  overflow: hidden;
  &-title {
    display: flex;
    align-items: center;
    height: 70px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    background: #ffffff;
    > p {
      text-align: center;
      font-size: 16px;
      color: #333;
    }
  }
  .el-pagination {
		white-space: nowrap;
		padding: 15px 5px;
		color: #303133;
		font-weight: bold;
	}
  .addDate {
    margin: 20px 32px 10px 32px;
    height: 32px;
    border-radius: 3px;
    text-align: center;
    line-height: 32px;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    border: 1px dashed rgba(0, 0, 0, 0.25);
  }
  .el-button--text {
    margin: 0 10px;
  }
}
// .dialog{
//   height: 350px;
//   overflow-y: auto;
// }
/deep/.el-dialog__body{
  padding: 10px 20px;
}
.change1{
  display: flex;
  padding: 20px 20px 20px 0;
  flex-wrap: wrap;
  > p {
    width: 100%;
    font-size: 14px;
    display: flex;
    margin: 10px 0;
    align-items: center;
    color: #999;
    > span {
      display: block;
      width: 120px;
      text-align: right;
      padding-right: 15px;
      color: #18A05E;
    }
  }
}
.change {
  display: flex;
  padding-right: 20px;
  flex-wrap: wrap;
  .fuxuan{
    display: flex;
    justify-content: center;
    margin: 10px auto;
  }
  > p {
    width: 100%;
    font-size: 14px;
    display: flex;
    margin: 10px 0;
    align-items: center;
    color: #333;
    /deep/.el-input__inner {
      width: inherit;
      background: none;
      height: 32px;
      // line-height: 32px;
      color: #333;
      border: 1px solid rgba(0, 0, 0, 0.1);
      padding: 0 25px;
    }
    /deep/.el-input__icon {
      line-height: 32px;
    }
    .userselect {
      // max-width: 250px;
      flex: 1;
    }

    > span {
      display: block;
      width: 120px;
      text-align: right;
      padding-right: 15px;
    }
    > input {
      width: inherit;
      flex: 1;
      height: 32px;
      border-radius: 3px;
      border: 1px solid rgba(0, 0, 0, 0.1);
      padding-left: 10px;
      color: #333;
    }
  }
}
</style>
